<?php


/*
 * Created on Jul 8, 2009
 *
 * To change the template for this generated file go to
 * Window - Preferences - PHPeclipse - PHP - Code Templates
 */
?>
<?php

require_once APPPATH."models/model_dao.php";
class Model_c1 extends Model_dao {

	function Model_c1() {
		// Call the Model constructor
		parent :: Model_dao("tbl_c1");
	}

	function find_by_nodeid($node_id) {
		$this->db->where("main", $node_id);
		$query = $this->db->get($this->_tbl_name);
		if ($query->num_rows() > 0) {
			return $query->result_array();
		}
		return null;
	}

	function find_by_id($id) {
		$this->db->where($this->_tbl_pri, $id);
		$query = $this->db->get($this->_tbl_name);

		if ($query->num_rows() > 0) {
			return $query->first_row('array');
		}
		return null;
	}

	function search_total($templates, $keyword){
		$this->db->where("searchable", 1);
		$this->db->where_in("temp", $templates);
		$this->db->like('t2', $keyword);
		$query = $this->db->get($this->_tbl_name);
		//echo $this->db->last_query();
		if ($query->num_rows() > 0) {
			return $query->num_rows();
		}
		return 0;
	}

	function search($templates, $keyword, $start, $limit){
		$this->db->where("searchable", 1);
		$this->db->where_in("temp", $templates);
		$this->db->like('t2', $keyword);
		$this->db->limit($limit, $start);
		$query = $this->db->get($this->_tbl_name);
		//echo $this->db->last_query();
		if ($query->num_rows() > 0) {
			return $query->result_array();
		}
		return null;
	}

	function update($id, $data) {
		$this->db->where('id', $id);
		$this->db->update($this->_tbl_name, $data);
	}
}
?>